<!--关于我们-->
<template>
  <div class="all bg1">
    
    <!-- 二维码 -->
    <div class="acenter">
    
    <div class="height40"></div>
    <template v-if="oldInfo">
      <text class="font24 text3" v-if="oldInfo.bundleVersion == undefined || oldInfo.bundleVersion == 0">
          {{T('版本')+'：'+oldInfo.versionName+"_20"}}</text>
      <text class="font24 text3" v-else>{{T('版本')+'：'+oldInfo.versionName+'_'+oldInfo.bundleVersion}}</text>
    </template>

      <div class="qr-code-box">
        <WeexQRCode class="qr-code" :code="codeUrl"></WeexQRCode>
      </div>
      
      <text class="font24 text2">{{T('扫码下载Vtrading-APP')}}</text>
    </div>
    
    <!-- 功能列表 -->
    <template>
      <div class="cell bt1" @click="shareClick">
        <text class="font30 text2 all">{{T('分享Vtrading')}}</text>
        <LImage class="img-arrow" :src="Config.img('jiantou_hui.png')"></LImage>
      </div>
      <div class="line line1"></div>

      <div class="cell bt1" @click="protocolClick">
        <text class="font30 text2 all">{{T('用户协议')}}</text>
        <LImage class="img-arrow" :src="Config.img('jiantou_hui.png')"></LImage>
      </div>
      <div class="line line1"></div>

      <div class="cell bt1" @click="upClick">
        <text class="font30 text2 all">{{T('检查更新')}}</text>
        <div v-if="hasNew" class="tag main1"></div>
        <LImage class="img-arrow" :src="Config.img('jiantou_hui.png')"></LImage>
      </div>
      <div class="line line1"></div>

      <div class="cell bt1" @click="stClick">
        <text class="font30 text2 all">{{T('Vtrading生态')}}</text>
        <LImage class="img-arrow" :src="Config.img('jiantou_hui.png')"></LImage>
      </div>
      <div class="line line1"></div>
    </template>
  </div>
</template>

<style src="@/_css/style.css" ></style>
<style scoped>
.qr-code-box{
  justify-content: center;
  align-items: center;
  background-color:#ffffff;

  width:300px;
  height:300px;
  border-radius: 4px;

  margin-top:30px;
  margin-bottom: 30px;
}
.qr-code{
  width:280px;
  height:280px;
}
.cell {
  flex-direction: row;
  align-items: center;
  height:118px;

  padding-left: 40px;
  padding-right: 40px;
}
.line{
  height: 1px;
  margin-left: 40px;
}
.img-arrow {
  width: 16px;
  height: 26px;
}
.tag{
  width:14px;
  height:14px;
  margin-right:30px;
  border-radius:50%;
}
</style>

<script>

import jnavigator from "@/_js/navigator";
import jmodal from "@/_js/modal";
import jconfig from "@/_js/config";
import jhttps from "@/_js/https"; ;
import jdebug from "@/_js/debug"; ;

const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;

weexFunction.setTitle(T('关于我们'));

//关于界面
export default {
  
  data() {
    return {
      T:T,
      Config:jconfig,
      codeUrl: jconfig.inviteUrl,

      oldInfo:undefined, //旧版本信息
      newInfo:undefined, //新版本信息
      hasNew:false, //turn 需要更新
    };
  },

  created(){

    //获取版本信息
    weexFunction.getVersionCode((data)=>{
      this.oldInfo = JSON.parse(data);
      this.httpCheckVersion();
    });
  },
  
  methods: {
    
    /********************************** HTTP*/
    //检查更新
    httpCheckVersion(){
      
      var param = {"osType":this.oldInfo.osType};
      jhttps.post("systemV2/checkVersionV2", param,false,(data)=>{
        if(data.status == 200){
          this.newInfo = data.data;
          this.hasNew = parseInt(this.newInfo.versionCode) > parseInt(this.oldInfo.versionCode) || 
          (this.oldInfo.bundleVersion && 
          parseInt(this.newInfo.versionCode) == parseInt(this.oldInfo.versionCode) &&
            parseInt(this.newInfo.bundleVersionCode) > parseInt(this.oldInfo.bundleVersion));
        } else{
        }
      });
    },

    /********************************** 点击事件*/
    //分享Vtrading
    shareClick(){
      weexFunction.shareApp();
    },

    //用户协议
    protocolClick(){
      var nav = {'navColor':'#0c0c0c'};
      jnavigator.open("", "mine/Protocol", undefined, nav);
    },

    //检查更新
    upClick(){
      if(!this.hasNew){
        jmodal.toast(T('已经是最新版本'));
        return;
      }

      jnavigator.openDialog("DialogUpgrade", {'upgradeInfo':JSON.stringify(this.newInfo)});
    },

    //生态
    stClick() {
      var nav = {'navColor':'#0c0c0c'};
      jnavigator.open("", "mine/ShengTai", undefined, nav);
    }
  }
};

</script>
